package com.wtpaint.lib.glide.load;

import com.wtpaint.lib.glide.cache.Key;

import java.security.MessageDigest;

public class ObjectKey implements Key {

    private final Object obj;

    public ObjectKey(Object obj) {
        this.obj = obj;
    }

    @Override
    public void updateDiskCacheKey(MessageDigest md) {
        md.update(obj.toString().getBytes());
    }

    @Override
    public byte[] getKeyBytes() {
        return new byte[0];
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null || getClass() != obj.getClass()) return false;
        ObjectKey objectKey = (ObjectKey) obj;

        return this.obj != null ? this.obj.equals(objectKey.obj) : objectKey.obj == null;
    }

    @Override
    public int hashCode() {
        return this.obj != null ? obj.hashCode() : 0;
    }
}
